<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>02人员管理</title>
    <script src="https://cdn.tailwindcss.com"></script>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }
        
        body {
            font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', 'Helvetica Neue', Helvetica, Arial, sans-serif;
            background-color: #f5f7fa;
        }
        
        .status-dot {
            width: 8px;
            height: 8px;
            border-radius: 50%;
            display: inline-block;
            animation: pulse 2s infinite;
        }
        
        .status-online { background-color: #52c41a; }
        .status-offline { background-color: #8c8c8c; }
        .status-busy { background-color: #ff4d4f; }
        .status-leave { background-color: #faad14; }
        
        @keyframes pulse {
            0% { opacity: 1; }
            50% { opacity: 0.5; }
            100% { opacity: 1; }
        }
        
        .person-card {
            transition: all 0.3s ease;
            cursor: pointer;
            border: 1px solid #e8e8e8;
            border-radius: 8px;
            background: white;
        }
        
        .person-card:hover {
            box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
            transform: translateY(-2px);
        }
        
        .person-card.active {
            background: linear-gradient(135deg, #e6f7ff 0%, #ffffff 100%);
            border: 1px solid #1890ff;
            box-shadow: 0 2px 8px rgba(24, 144, 255, 0.2);
        }
        
        .stat-card {
            transition: all 0.3s ease;
            border-radius: 12px;
            background: white;
            box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
            position: relative;
            overflow: hidden;
        }
        
        .stat-card:hover {
            transform: translateY(-4px);
            box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
        }
        
        .stat-card::before {
            content: '';
            position: absolute;
            top: 0;
            left: 0;
            right: 0;
            height: 4px;
            background: linear-gradient(90deg, var(--card-color) 0%, var(--card-color-light) 100%);
        }
        
        .stat-blue {
            --card-color: #1890ff;
            --card-color-light: #40a9ff;
        }
        
        .stat-green {
            --card-color: #52c41a;
            --card-color-light: #73d13d;
        }
        
        .stat-orange {
            --card-color: #fa8c16;
            --card-color-light: #ffa940;
        }
        
        .stat-purple {
            --card-color: #722ed1;
            --card-color-light: #9254de;
        }
        
        .stat-icon {
            width: 40px;
            height: 40px;
            border-radius: 10px;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 20px;
        }
        
        .stat-blue .stat-icon {
            background: linear-gradient(135deg, #e6f7ff 0%, #bae7ff 100%);
            color: #1890ff;
        }
        
        .stat-green .stat-icon {
            background: linear-gradient(135deg, #f6ffed 0%, #d9f7be 100%);
            color: #52c41a;
        }
        
        .stat-orange .stat-icon {
            background: linear-gradient(135deg, #fff7e6 0%, #ffd591 100%);
            color: #fa8c16;
        }
        
        .stat-purple .stat-icon {
            background: linear-gradient(135deg, #f9f0ff 0%, #efdbff 100%);
            color: #722ed1;
        }
        
        .nav-item {
            position: relative;
            transition: all 0.3s ease;
            border-radius: 6px;
        }
        
        .nav-item:hover {
            background-color: #f0f5ff;
            color: #1890ff;
        }
        
        .nav-item.active {
            color: #1890ff;
            background-color: #e6f7ff;
        }
        
        .modal {
            display: none;
            animation: fadeIn 0.3s ease;
        }
        
        .modal.show {
            display: flex;
        }
        
        @keyframes fadeIn {
            from { opacity: 0; }
            to { opacity: 1; }
        }
        
        .btn-primary {
            background: linear-gradient(135deg, #1890ff 0%, #096dd9 100%);
            transition: all 0.3s ease;
            border: none;
            border-radius: 6px;
        }
        
        .btn-primary:hover {
            transform: translateY(-2px);
            box-shadow: 0 4px 12px rgba(24, 144, 255, 0.4);
        }
        
        .search-input:focus {
            box-shadow: 0 0 0 2px rgba(24, 144, 255, 0.2);
            border-color: #1890ff;
        }

        /* 状态文字样式 */
        .status-text {
            font-size: 11px;
            font-weight: 500;
            padding: 2px 8px;
            border-radius: 12px;
        }

        .status-text-online {
            background-color: #f6ffed;
            color: #52c41a;
            border: 1px solid #b7eb8f;
        }

        .status-text-busy {
            background-color: #fff2f0;
            color: #ff4d4f;
            border: 1px solid #ffccc7;
        }

        .status-text-offline {
            background-color: #f5f5f5;
            color: #8c8c8c;
            border: 1px solid #d9d9d9;
        }

        .status-text-leave {
            background-color: #fffbe6;
            color: #faad14;
            border: 1px solid #ffe58f;
        }

        /* 滚动条样式 */
        ::-webkit-scrollbar {
            width: 6px;
            height: 6px;
        }

        ::-webkit-scrollbar-track {
            background: #f1f1f1;
            border-radius: 3px;
        }

        ::-webkit-scrollbar-thumb {
            background: #c1c1c1;
            border-radius: 3px;
        }

        ::-webkit-scrollbar-thumb:hover {
            background: #a8a8a8;
        }

        /* 数字动画效果 */
        .stat-number {
            font-variant-numeric: tabular-nums;
            letter-spacing: -0.5px;
        }

        /* 紧凑型统计卡片样式 */
        .compact-stat-card {
            padding: 16px;
        }

        .compact-stat-card .stat-icon {
            width: 36px;
            height: 36px;
            font-size: 16px;
            border-radius: 8px;
        }

        .compact-stat-card .stat-number {
            font-size: 1.5rem;
        }

        .compact-stat-card p {
            font-size: 0.75rem;
        }

        /* 添加操作按钮样式 */
        .action-btn {
            display: inline-flex;
            align-items: center;
            justify-content: center;
            padding: 8px 16px;
            border-radius: 6px;
            font-size: 14px;
            font-weight: 500;
            transition: all 0.3s ease;
            cursor: pointer;
            border: none;
        }

        .action-btn-primary {
            background: linear-gradient(135deg, #1890ff 0%, #096dd9 100%);
            color: white;
        }

        .action-btn-primary:hover {
            transform: translateY(-2px);
            box-shadow: 0 4px 12px rgba(24, 144, 255, 0.4);
        }

        .action-btn-success {
            background: linear-gradient(135deg, #52c41a 0%, #389e0d 100%);
            color: white;
        }

        .action-btn-success:hover {
            transform: translateY(-2px);
            box-shadow: 0 4px 12px rgba(82, 196, 26, 0.4);
        }

        .action-btn-warning {
            background: linear-gradient(135deg, #fa8c16 0%, #d46b08 100%);
            color: white;
        }

        .action-btn-warning:hover {
            transform: translateY(-2px);
            box-shadow: 0 4px 12px rgba(250, 140, 22, 0.4);
        }

        /* 证书相关样式 */
        .certificate-item {
            border: 1px solid #e8e8e8;
            border-radius: 8px;
            padding: 12px;
            margin-bottom: 12px;
            background: #fafafa;
            transition: all 0.3s ease;
        }

        .certificate-item:hover {
            box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
            background: #f5f5f5;
        }

        .certificate-status {
            display: inline-block;
            padding: 2px 8px;
            border-radius: 12px;
            font-size: 11px;
            font-weight: 500;
        }

        .certificate-valid {
            background-color: #f6ffed;
            color: #52c41a;
            border: 1px solid #b7eb8f;
        }

        .certificate-expiring {
            background-color: #fff7e6;
            color: #fa8c16;
            border: 1px solid #ffd591;
        }

        .certificate-expired {
            background-color: #fff2f0;
            color: #ff4d4f;
            border: 1px solid #ffccc7;
        }

        .certificate-form-row {
            display: grid;
            grid-template-columns: repeat(2, 1fr);
            gap: 12px;
            margin-bottom: 12px;
        }

        .certificate-form-row.full-width {
            grid-template-columns: 1fr;
        }

        .add-certificate-btn {
            border: 1px dashed #d9d9d9;
            background: #fafafa;
            color: #8c8c8c;
            padding: 12px;
            border-radius: 8px;
            cursor: pointer;
            transition: all 0.3s ease;
            display: flex;
            align-items: center;
            justify-content: center;
        }

        .add-certificate-btn:hover {
            border-color: #1890ff;
            color: #1890ff;
            background: #f0f5ff;
        }

        .remove-certificate-btn {
            color: #ff4d4f;
            cursor: pointer;
            transition: all 0.3s ease;
        }

        .remove-certificate-btn:hover {
            color: #ff7875;
            transform: scale(1.1);
        }

        /* 证书选择器样式 */
        .certificate-selector {
            display: flex;
            flex-wrap: wrap;
            gap: 8px;
            margin-top: 8px;
        }

        .certificate-chip {
            padding: 4px 12px;
            border-radius: 16px;
            background: #f0f5ff;
            color: #1890ff;
            border: 1px solid #d6e4ff;
            font-size: 12px;
            cursor: pointer;
            transition: all 0.3s ease;
        }

        .certificate-chip:hover {
            background: #e6f7ff;
            border-color: #91caff;
        }

        .certificate-chip.selected {
            background: #1890ff;
            color: white;
            border-color: #1890ff;
        }

        /* 证书详情卡片样式 */
        .certificate-detail-card {
            background: white;
            border: 1px solid #e8e8e8;
            border-radius: 8px;
            padding: 12px;
            margin-bottom: 8px;
            transition: all 0.3s ease;
        }

        .certificate-detail-card:hover {
            box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
            transform: translateY(-1px);
        }

        .certificate-detail-header {
            display: flex;
            justify-content: between;
            align-items: center;
            margin-bottom: 8px;
        }

        .certificate-detail-info {
            display: grid;
            grid-template-columns: repeat(2, 1fr);
            gap: 8px;
            font-size: 12px;
        }

        .certificate-detail-info span {
            color: #666;
        }

        .certificate-detail-info strong {
            color: #333;
        }
    </style>
</head>
<body>
    <!-- 顶部标题栏 -->
    <header style="background: linear-gradient(135deg, #3B82F6 0%, #1E40AF 100%);" class="text-white py-2.5 px-6 shadow-xl">
        <div class="flex justify-between items-center">
            <div class="flex-1"></div>
            <h1 class="text-3xl font-bold flex-1 text-center tracking-wide">马鞍山非急救转运调度中心</h1>
            <div class="flex-1 flex justify-end items-center space-x-4">
                <div style="background: rgba(255, 255, 255, 0.2);" class="flex items-center space-x-3 px-4 py-2 rounded-full backdrop-blur-sm">
                    <i class="fas fa-user-circle text-xl"></i>
                    <span class="font-medium">调度员 张晓丽</span>
                </div>
                <button style="transition: all 0.3s ease;" class="text-white hover:bg-white/20 p-3 rounded-full transition-all duration-300 hover:rotate-90">
                    <i class="fas fa-cog text-xl"></i>
                </button>
            </div>
        </div>
    </header>

    <!-- 导航栏 -->
    <nav style="background: rgba(255, 255, 255, 0.95); backdrop-filter: blur(10px); border: 1px solid rgba(255, 255, 255, 0.2);" class="shadow-lg sticky top-0 z-50">
        <div class="flex justify-center">
            <a href="#" class="nav-item px-8 py-4 text-gray-700 flex items-center space-x-3" style="position: relative; transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1); overflow: hidden;" onmouseover="this.style.background='linear-gradient(180deg, rgba(59, 130, 246, 0.05) 0%, rgba(30, 64, 175, 0.05) 100%)'; this.style.transform='translateY(-1px)'; this.querySelector('i').style.transform='scale(1.1)';" onmouseout="this.style.background=''; this.style.transform=''; this.querySelector('i').style.transform='';">
                <i class="fas fa-th-large text-lg" style="transition: all 0.3s ease;"></i>
                <span>调度中心</span>
            </a>
            <a href="#" class="nav-item px-8 py-4 text-gray-700 flex items-center space-x-3" style="position: relative; transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1); overflow: hidden;" onmouseover="this.style.background='linear-gradient(180deg, rgba(59, 130, 246, 0.05) 0%, rgba(30, 64, 175, 0.05) 100%)'; this.style.transform='translateY(-1px)'; this.querySelector('i').style.transform='scale(1.1)';" onmouseout="this.style.background=''; this.style.transform=''; this.querySelector('i').style.transform='';">
                <i class="fas fa-clipboard-list text-lg" style="transition: all 0.3s ease;"></i>
                <span>订单管理</span>
            </a>
            <a href="#" class="nav-item active px-8 py-4 text-gray-700 flex items-center space-x-3" style="position: relative; transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1); overflow: hidden; color: #3B82F6; font-weight: 600;">
                <i class="fas fa-users text-lg" style="transition: all 0.3s ease;"></i>
                <span>人员管理</span>
                <span style="content: ''; position: absolute; bottom: 0; left: 50%; width: 80%; height: 3px; background: linear-gradient(90deg, #3B82F6, #1E40AF); transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1); transform: translateX(-50%);"></span>
            </a>
            <a href="#" class="nav-item px-8 py-4 text-gray-700 flex items-center space-x-3" style="position: relative; transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1); overflow: hidden;" onmouseover="this.style.background='linear-gradient(180deg, rgba(59, 130, 246, 0.05) 0%, rgba(30, 64, 175, 0.05) 100%)'; this.style.transform='translateY(-1px)'; this.querySelector('i').style.transform='scale(1.1)';" onmouseout="this.style.background=''; this.style.transform=''; this.querySelector('i').style.transform='';">
                <i class="fas fa-ambulance text-lg" style="transition: all 0.3s ease;"></i>
                <span>车辆管理</span>
            </a>
            <a href="#" class="nav-item px-8 py-4 text-gray-700 flex items-center space-x-3" style="position: relative; transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1); overflow: hidden;" onmouseover="this.style.background='linear-gradient(180deg, rgba(59, 130, 246, 0.05) 0%, rgba(30, 64, 175, 0.05) 100%)'; this.style.transform='translateY(-1px)'; this.querySelector('i').style.transform='scale(1.1)';" onmouseout="this.style.background=''; this.style.transform=''; this.querySelector('i').style.transform='';">
                <i class="fas fa-truck text-lg" style="transition: all 0.3s ease;"></i>
                <span>车辆状态</span>
            </a>
            <a href="#" class="nav-item px-8 py-4 text-gray-700 flex items-center space-x-3" style="position: relative; transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1); overflow: hidden;" onmouseover="this.style.background='linear-gradient(180deg, rgba(59, 130, 246, 0.05) 0%, rgba(30, 64, 175, 0.05) 100%)'; this.style.transform='translateY(-1px)'; this.querySelector('i').style.transform='scale(1.1)';" onmouseout="this.style.background=''; this.style.transform=''; this.querySelector('i').style.transform='';">
                <i class="fas fa-map-marked-alt text-lg" style="transition: all 0.3s ease;"></i>
                <span>实时监控</span>
            </a>
            <a href="#" class="nav-item px-8 py-4 text-gray-700 flex items-center space-x-3" style="position: relative; transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1); overflow: hidden;" onmouseover="this.style.background='linear-gradient(180deg, rgba(59, 130, 246, 0.05) 0%, rgba(30, 64, 175, 0.05) 100%)'; this.style.transform='translateY(-1px)'; this.querySelector('i').style.transform='scale(1.1)';" onmouseout="this.style.background=''; this.style.transform=''; this.querySelector('i').style.transform='';">
                <i class="fas fa-coins text-lg" style="transition: all 0.3s ease;"></i>
                <span>财务管理</span>
            </a>
        </div>
    </nav>

    <!-- 主体内容区域 -->
    <main class="px-6 pt-6 pb-8">
        <div class="flex gap-6 mt-6">
            <!-- 左侧人员列表区域 -->
            <aside class="w-80 bg-white rounded-lg shadow-sm border border-gray-200 flex-shrink-0">
                <div class="p-4">
                    <!-- 分类标签页 -->
                    <div class="mb-4">
                        <div class="flex space-x-1 border-b border-gray-200">
                            <button class="tab-btn px-3 py-2 text-xs font-medium text-blue-600 border-b-2 border-blue-600" data-tab="all">
                                全部人员
                            </button>
                            <button class="tab-btn px-3 py-2 text-xs font-medium text-gray-600 hover:text-blue-600" data-tab="medical">
                                医护人员
                            </button>
                            <button class="tab-btn px-3 py-2 text-xs font-medium text-gray-600 hover:text-blue-600" data-tab="driver">
                                司机
                            </button>
                            <button class="tab-btn px-3 py-2 text-xs font-medium text-gray-600 hover:text-blue-600" data-tab="dispatcher">
                                调度员
                            </button>
                        </div>
                    </div>

                    <!-- 搜索框 -->
                    <div class="mb-4">
                        <div class="relative">
                            <input type="text" 
                                   id="searchInput"
                                   placeholder="搜索姓名、工号、部门..." 
                                   class="search-input w-full px-3 py-2 pl-9 text-sm border border-gray-300 rounded-lg focus:outline-none transition-all">
                            <i class="fas fa-search absolute left-3 top-2.5 text-gray-400 text-sm"></i>
                        </div>
                    </div>

                    <!-- 人员列表 -->
                    <div id="personList" class="space-y-3 overflow-y-auto pr-1" style="max-height: 850px;">
                        <!-- 人员卡片将通过JavaScript动态生成 -->
                    </div>
                </div>
            </aside>

          <!-- 右侧功能操作区域 -->
            <section class="flex-1 min-w-0 space-y-4">
                <!-- 人员状态统计看板 -->
                <div class="bg-white rounded-lg shadow-sm border border-gray-200 p-6">
                    <div class="flex justify-between items-center mb-6">
                        <h3 class="text-lg font-semibold text-gray-900">
                            <i class="fas fa-chart-pie text-blue-600 mr-2"></i>人员管理</h3>
                        <div class="flex items-center space-x-4">
                            <!-- 操作按钮组 -->
                            <div class="flex space-x-2">
                                <button onclick="showAddModal()" class="action-btn action-btn-primary px-4 py-2 text-sm rounded-lg flex items-center space-x-2">
                                    <i class="fas fa-user-plus"></i>
                                    <span>添加新员工</span>
                                </button>
                                <button class="action-btn action-btn-success px-4 py-2 text-sm rounded-lg flex items-center space-x-2">
                                    <i class="fas fa-file-import"></i>
                                    <span>批量导入</span>
                                </button>
                                <button class="action-btn action-btn-warning px-4 py-2 text-sm rounded-lg flex items-center space-x-2">
                                    <i class="fas fa-file-export"></i>
                                    <span>导出数据</span>
                                </button>
                            </div>
                        </div>
                    </div>

                    <div class="grid grid-cols-7 gap-4">
                        <!-- 总人数 -->
                        <div class="stat-card stat-blue compact-stat-card p-4">
                            <div class="flex items-center justify-between">
                                <div>
                                    <p class="text-gray-600 text-xs mb-1">总人数</p>
                                    <p class="stat-number text-2xl font-bold text-gray-900">286</p>
                                </div>
                                <div class="stat-icon">
                                    <i class="fas fa-users"></i>
                                </div>
                            </div>
                        </div>
                        
                        <!-- 在线人数 -->
                        <div class="stat-card stat-green compact-stat-card p-4">
                            <div class="flex items-center justify-between">
                                <div>
                                    <p class="text-gray-600 text-xs mb-1">在线人数</p>
                                    <p class="stat-number text-2xl font-bold text-gray-900">189</p>
                                </div>
                                <div class="stat-icon">
                                    <i class="fas fa-circle"></i>
                                </div>
                            </div>
                        </div>
                        
                        <!-- 任务中 -->
                        <div class="stat-card stat-orange compact-stat-card p-4">
                            <div class="flex items-center justify-between">
                                <div>
                                    <p class="text-gray-600 text-xs mb-1">任务中</p>
                                    <p class="stat-number text-2xl font-bold text-gray-900">92</p>
                                </div>
                                <div class="stat-icon">
                                    <i class="fas fa-tasks"></i>
                                </div>
                            </div>
                        </div>
                        
                        <!-- 休假人数 -->
                        <div class="stat-card stat-purple compact-stat-card p-4">
                            <div class="flex items-center justify-between">
                                <div>
                                    <p class="text-gray-600 text-xs mb-1">休假人数</p>
                                    <p class="stat-number text-2xl font-bold text-gray-900">45</p>
                                </div>
                                <div class="stat-icon">
                                    <i class="fas fa-umbrella-beach"></i>
                                </div>
                            </div>
                        </div>

                        <!-- 医护人员 -->
                        <div class="bg-blue-50 rounded-lg p-4 border border-blue-200">
                            <div class="flex items-center justify-between">
                                <div>
                                    <p class="text-blue-700 text-xs font-medium">医护人员</p>
                                    <p class="text-lg font-bold text-blue-900 mt-1">98人</p>
                                    <p class="text-xs text-blue-600 mt-1">34.3%</p>
                                </div>
                                <i class="fas fa-user-nurse text-xl text-blue-500"></i>
                            </div>
                        </div>
                        
                        <!-- 司机 -->
                        <div class="bg-green-50 rounded-lg p-4 border border-green-200">
                            <div class="flex items-center justify-between">
                                <div>
                                    <p class="text-green-700 text-xs font-medium">司机</p>
                                    <p class="text-lg font-bold text-green-900 mt-1">122人</p>
                                    <p class="text-xs text-green-600 mt-1">42.7%</p>
                                </div>
                                <i class="fas fa-id-card text-xl text-green-500"></i>
                            </div>
                        </div>
                        
                        <!-- 调度员 -->
                        <div class="bg-purple-50 rounded-lg p-4 border border-purple-200">
                            <div class="flex items-center justify-between">
                                <div>
                                    <p class="text-purple-700 text-xs font-medium">调度员</p>
                                    <p class="text-lg font-bold text-purple-900 mt-1">66人</p>
                                    <p class="text-xs text-purple-600 mt-1">23.0%</p>
                                </div>
                                <i class="fas fa-headset text-xl text-purple-500"></i>
                            </div>
                        </div>
                    </div>
                </div>
                
                <!-- 详细信息面板 -->
                <div class="bg-white rounded-lg shadow-sm border border-gray-200 p-5">
                    <div id="detailContent" class="space-y-4">
                        <!-- 陈曦的详细信息将在这里显示 -->
                    </div>
                </div>
            </section>
        </div>
    </main>

    <!-- 添加/编辑人员模态框 -->
    <div id="addModal" class="modal fixed inset-0 bg-black bg-opacity-50 z-50 items-center justify-center">
        <div class="bg-white rounded-lg shadow-xl w-full max-w-4xl mx-4 max-h-[90vh] overflow-y-auto">
            <div class="p-6 border-b border-gray-200">
                <div class="flex justify-between items-center">
                    <h3 class="text-lg font-semibold text-gray-900">
                        <i class="fas fa-user-plus text-blue-600 mr-2"></i>添加新员工
                    </h3>
                    <button onclick="closeModal()" class="text-gray-400 hover:text-gray-600">
                        <i class="fas fa-times text-xl"></i>
                    </button>
                </div>
            </div>
            
            <form id="addPersonForm" class="p-6">
                <!-- 基本信息 -->
                <div class="mb-6">
                    <h4 class="text-base font-medium text-gray-900 mb-4 flex items-center">
                        <i class="fas fa-user text-blue-600 mr-2"></i>基本信息
                    </h4>
                    <div class="grid grid-cols-2 gap-4">
                        <div>
                            <label class="block text-sm font-medium text-gray-700 mb-1">姓名 *</label>
                            <input type="text" name="name" required class="w-full px-3 py-2 border border-gray-300 rounded-lg focus:outline-none focus:border-blue-500">
                        </div>
                        <div>
                            <label class="block text-sm font-medium text-gray-700 mb-1">工号 *</label>
                            <input type="text" name="employeeId" required class="w-full px-3 py-2 border border-gray-300 rounded-lg focus:outline-none focus:border-blue-500">
                        </div>
                        <div>
                            <label class="block text-sm font-medium text-gray-700 mb-1">性别</label>
                            <select name="gender" class="w-full px-3 py-2 border border-gray-300 rounded-lg focus:outline-none focus:border-blue-500">
                                <option value="男">男</option>
                                <option value="女">女</option>
                            </select>
                        </div>
                        <div>
                            <label class="block text-sm font-medium text-gray-700 mb-1">年龄</label>
                            <input type="number" name="age" class="w-full px-3 py-2 border border-gray-300 rounded-lg focus:outline-none focus:border-blue-500">
                        </div>
                        <div>
                            <label class="block text-sm font-medium text-gray-700 mb-1">岗位 *</label>
                            <select name="position" required class="w-full px-3 py-2 border border-gray-300 rounded-lg focus:outline-none focus:border-blue-500">
                                <option value="">请选择</option>
                                <option value="医护人员">医护人员</option>
                                <option value="司机">司机</option>
                                <option value="调度员">调度员</option>
                            </select>
                        </div>
                        <div>
                            <label class="block text-sm font-medium text-gray-700 mb-1">部门</label>
                            <input type="text" name="department" class="w-full px-3 py-2 border border-gray-300 rounded-lg focus:outline-none focus:border-blue-500">
                        </div>
                        <div>
                            <label class="block text-sm font-medium text-gray-700 mb-1">联系方式 *</label>
                            <input type="tel" name="phone" required class="w-full px-3 py-2 border border-gray-300 rounded-lg focus:outline-none focus:border-blue-500">
                        </div>
                        <div>
                            <label class="block text-sm font-medium text-gray-700 mb-1">入职时间</label>
                            <input type="date" name="joinDate" class="w-full px-3 py-2 border border-gray-300 rounded-lg focus:outline-none focus:border-blue-500">
                        </div>
                    </div>
                </div>

                <!-- 资质证书 -->
                <div class="mb-6">
                    <h4 class="text-base font-medium text-gray-900 mb-4 flex items-center justify-between">
                        <span>
                            <i class="fas fa-certificate text-blue-600 mr-2"></i>资质证书
                        </span>
                        <button type="button" onclick="addCertificate()" class="text-sm text-blue-600 hover:text-blue-700">
                            <i class="fas fa-plus-circle mr-1"></i>添加证书
                        </button>
                    </h4>
                    
                    <!-- 常用证书快速选择 -->
                    <div class="mb-4">
                        <p class="text-sm text-gray-600 mb-2">常用证书：</p>
                        <div class="certificate-selector">
                            <div class="certificate-chip" onclick="selectCommonCertificate(this, '医师资格证')">医师资格证</div>
                            <div class="certificate-chip" onclick="selectCommonCertificate(this, '护士执业证')">护士执业证</div>
                            <div class="certificate-chip" onclick="selectCommonCertificate(this, '急救证书')">急救证书</div>
                            <div class="certificate-chip" onclick="selectCommonCertificate(this, '驾驶证')">驾驶证</div>
                            <div class="certificate-chip" onclick="selectCommonCertificate(this, '救护车驾驶资格证')">救护车驾驶资格证</div>
                            <div class="certificate-chip" onclick="selectCommonCertificate(this, '心理咨询师证')">心理咨询师证</div>
                            <div class="certificate-chip" onclick="selectCommonCertificate(this, '康复治疗师证')">康复治疗师证</div>
                            <div class="certificate-chip" onclick="selectCommonCertificate(this, '护理员证')">护理员证</div>
                        </div>
                    </div>

                    <div id="certificatesList" class="space-y-3">
                        <!-- 证书列表将通过JavaScript动态生成 -->
                    </div>
                </div>
                
                <div class="flex justify-end space-x-3 pt-4">
                    <button type="button" onclick="closeModal()" class="px-4 py-2 bg-gray-200 text-gray-700 rounded-lg hover:bg-gray-300 transition-colors">
                        取消
                    </button>
                    <button type="submit" class="px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 transition-colors">
                        <i class="fas fa-save mr-2"></i>保存
                    </button>
                </div>
            </form>
        </div>
    </div>

    <!-- 确认对话框 -->
    <div id="confirmDialog" class="modal fixed inset-0 bg-black bg-opacity-50 z-50 items-center justify-center">
        <div class="bg-white rounded-lg shadow-xl w-full max-w-md mx-4">
            <div class="p-6">
                <div class="flex items-center mb-4">
                    <i class="fas fa-exclamation-triangle text-yellow-500 text-2xl mr-3"></i>
                    <h3 class="text-lg font-semibold text-gray-900">确认操作</h3>
                </div>
                <p id="confirmMessage" class="text-gray-600 mb-6">您确定要执行此操作吗？</p>
                <div class="flex justify-end space-x-3">
                    <button onclick="closeConfirmDialog()" class="px-4 py-2 bg-gray-200 text-gray-700 rounded-lg hover:bg-gray-300 transition-colors">
                        取消
                    </button>
                    <button id="confirmBtn" class="px-4 py-2 bg-red-600 text-white rounded-lg hover:bg-red-700 transition-colors">
                        确认
                    </button>
                </div>
            </div>
        </div>
    </div>

    <script>
        // 模拟真实风格姓名的人员数据，包含证书信息
        const personsData = [
            { 
                id: 1, 
                name: '陈曦', 
                employeeId: 'EMP001', 
                position: '医护人员', 
                department: '急救科', 
                phone: '13800138001', 
                status: 'online', 
                gender: '女', 
                age: 28, 
                joinDate: '2022-03-15', 
                lastOnline: '刚刚',
                certificates: [
                    {
                        name: '医师资格证',
                        number: 'DOC20220315001',
                        issuer: '国家卫生健康委员会',
                        issueDate: '2022-03-15',
                        expiryDate: '2027-03-14',
                        status: 'valid'
                    },
                    {
                        name: '急救证书',
                        number: 'EMT20220315002',
                        issuer: '中国红十字会',
                        issueDate: '2022-04-20',
                        expiryDate: '2025-04-19',
                        status: 'valid'
                    }
                ]
            },
            { 
                id: 2, 
                name: '林浩', 
                employeeId: 'EMP002', 
                position: '司机', 
                department: '运输部', 
                phone: '13800138002', 
                status: 'busy', 
                gender: '男', 
                age: 35, 
                joinDate: '2021-08-20', 
                lastOnline: '10分钟前',
                certificates: [
                    {
                        name: '驾驶证',
                        number: 'B2202108001',
                        issuer: '马鞍山市公安局交通警察支队',
                        issueDate: '2021-08-20',
                        expiryDate: '2027-08-19',
                        status: 'valid'
                    },
                    {
                        name: '救护车驾驶资格证',
                        number: 'AMB2021082001',
                        issuer: '安徽省卫生健康委员会',
                        issueDate: '2021-09-15',
                        expiryDate: '2024-09-14',
                        status: 'expiring'
                    }
                ]
            },
            { 
                id: 3, 
                name: '赵玥', 
                employeeId: 'EMP003', 
                position: '调度员', 
                department: '调度中心', 
                phone: '13800138003', 
                status: 'online', 
                gender: '女', 
                age: 26, 
                joinDate: '2023-01-10', 
                lastOnline: '刚刚',
                certificates: [
                    {
                        name: '调度员资格证',
                        number: 'DIS2023011001',
                        issuer: '马鞍山市急救中心',
                        issueDate: '2023-01-10',
                        expiryDate: '2026-01-09',
                        status: 'valid'
                    }
                ]
            },
            { 
                id: 4, 
                name: '王磊', 
                employeeId: 'EMP004', 
                position: '医护人员', 
                department: '急救科', 
                phone: '13800138004', 
                status: 'offline', 
                gender: '男', 
                age: 32, 
                joinDate: '2022-06-01', 
                lastOnline: '2小时30分钟前',
                certificates: [
                    {
                        name: '护士执业证',
                        number: 'NUR2022060101',
                        issuer: '安徽省卫生健康委员会',
                        issueDate: '2022-06-01',
                        expiryDate: '2027-05-31',
                        status: 'valid'
                    }
                ]
            },
            { 
                id: 5, 
                name: '李婷', 
                employeeId: 'EMP005', 
                position: '司机', 
                department: '运输部', 
                phone: '13800138005', 
                status: 'online', 
                gender: '女', 
                age: 29, 
                joinDate: '2020-12-15', 
                lastOnline: '5分钟前',
                certificates: [
                    {
                        name: '驾驶证',
                        number: 'C2202012001',
                        issuer: '马鞍山市公安局交通警察支队',
                        issueDate: '2020-12-15',
                        expiryDate: '2026-12-14',
                        status: 'valid'
                    }
                ]
            },
            { 
                id: 6, 
                name: '张伟', 
                employeeId: 'EMP006', 
                position: '调度员', 
                department: '调度中心', 
                phone: '13800138006', 
                status: 'busy', 
                gender: '男', 
                age: 31, 
                joinDate: '2023-05-20', 
                lastOnline: '15分钟前',
                certificates: [
                    {
                        name: '调度员资格证',
                        number: 'DIS2023052001',
                        issuer: '马鞍山市急救中心',
                        issueDate: '2023-05-20',
                        expiryDate: '2026-05-19',
                        status: 'valid'
                    }
                ]
            },
            { 
                id: 7, 
                name: '刘洋', 
                employeeId: 'EMP007', 
                position: '医护人员', 
                department: '急救科', 
                phone: '13800138007', 
                status: 'online', 
                gender: '男', 
                age: 27, 
                joinDate: '2021-11-10', 
                lastOnline: '刚刚',
                certificates: [
                    {
                        name: '医师资格证',
                        number: 'DOC2021111001',
                        issuer: '国家卫生健康委员会',
                        issueDate: '2021-11-10',
                        expiryDate: '2026-11-09',
                        status: 'valid'
                    }
                ]
            },
            { 
                id: 8, 
                name: '周敏', 
                employeeId: 'EMP008', 
                position: '司机', 
                department: '运输部', 
                phone: '13800138008', 
                status: 'offline', 
                gender: '女', 
                age: 33, 
                joinDate: '2022-02-28', 
                lastOnline: '1天前',
                certificates: [
                    {
                        name: '驾驶证',
                        number: 'B2202028001',
                        issuer: '马鞍山市公安局交通警察支队',
                        issueDate: '2022-02-28',
                        expiryDate: '2028-02-27',
                        status: 'valid'
                    }
                ]
            },
            { 
                id: 9, 
                name: '吴鹏', 
                employeeId: 'EMP009', 
                position: '医护人员', 
                department: '急救科', 
                phone: '13800138009', 
                status: 'online', 
                gender: '男', 
                age: 30, 
                joinDate: '2022-09-15', 
                lastOnline: '刚刚',
                certificates: [
                    {
                        name: '急救证书',
                        number: 'EMT2022091501',
                        issuer: '中国红十字会',
                        issueDate: '2022-09-15',
                        expiryDate: '2025-09-14',
                        status: 'valid'
                    }
                ]
            },
            { 
                id: 10, 
                name: '孙娜', 
                employeeId: 'EMP010', 
                position: '司机', 
                department: '运输部', 
                phone: '13800138010', 
                status: 'busy', 
                gender: '女', 
                age: 28, 
                joinDate: '2021-03-20', 
                lastOnline: '20分钟前',
                certificates: [
                    {
                        name: '驾驶证',
                        number: 'C2201032001',
                        issuer: '马鞍山市公安局交通警察支队',
                        issueDate: '2021-03-20',
                        expiryDate: '2027-03-19',
                        status: 'valid'
                    }
                ]
            },
            { 
                id: 11, 
                name: '马超', 
                employeeId: 'EMP011', 
                position: '调度员', 
                department: '调度中心', 
                phone: '13800138011', 
                status: 'online', 
                gender: '男', 
                age: 34, 
                joinDate: '2022-07-10', 
                lastOnline: '刚刚',
                certificates: [
                    {
                        name: '调度员资格证',
                        number: 'DIS2022071001',
                        issuer: '马鞍山市急救中心',
                        issueDate: '2022-07-10',
                        expiryDate: '2025-07-09',
                        status: 'expiring'
                    }
                ]
            },
            { 
                id: 12, 
                name: '徐静', 
                employeeId: 'EMP012', 
                position: '医护人员', 
                department: '急救科', 
                phone: '13800138012', 
                status: 'leave', 
                gender: '女', 
                age: 29, 
                joinDate: '2020-11-25', 
                lastOnline: '3天前',
                certificates: [
                    {
                        name: '护士执业证',
                        number: 'NUR2020112501',
                        issuer: '安徽省卫生健康委员会',
                        issueDate: '2020-11-25',
                        expiryDate: '2025-11-24',
                        status: 'expiring'
                    }
                ]
            },
            { 
                id: 13, 
                name: '黄强', 
                employeeId: 'EMP013', 
                position: '司机', 
                department: '运输部', 
                phone: '13800138013', 
                status: 'online', 
                gender: '男', 
                age: 36, 
                joinDate: '2021-06-18', 
                lastOnline: '2分钟前',
                certificates: [
                    {
                        name: '驾驶证',
                        number: 'A2106061801',
                        issuer: '马鞍山市公安局交通警察支队',
                        issueDate: '2021-06-18',
                        expiryDate: '2027-06-17',
                        status: 'valid'
                    }
                ]
            },
            { 
                id: 14, 
                name: '朱丽', 
                employeeId: 'EMP014', 
                position: '调度员', 
                department: '调度中心', 
                phone: '13800138014', 
                status: 'busy', 
                gender: '女', 
                age: 25, 
                joinDate: '2023-02-14', 
                lastOnline: '8分钟前',
                certificates: [
                    {
                        name: '调度员资格证',
                        number: 'DIS2023021401',
                        issuer: '马鞍山市急救中心',
                        issueDate: '2023-02-14',
                        expiryDate: '2026-02-13',
                        status: 'valid'
                    }
                ]
            },
            { 
                id: 15, 
                name: '郭涛', 
                employeeId: 'EMP015', 
                position: '医护人员', 
                department: '急救科', 
                phone: '13800138015', 
                status: 'online', 
                gender: '男', 
                age: 31, 
                joinDate: '2022-01-05', 
                lastOnline: '刚刚',
                certificates: [
                    {
                        name: '医师资格证',
                        number: 'DOC2022010501',
                        issuer: '国家卫生健康委员会',
                        issueDate: '2022-01-05',
                        expiryDate: '2027-01-04',
                        status: 'valid'
                    }
                ]
            },
            { 
                id: 16, 
                name: '何琳', 
                employeeId: 'EMP016', 
                position: '司机', 
                department: '运输部', 
                phone: '13800138016', 
                status: 'offline', 
                gender: '女', 
                age: 32, 
                joinDate: '2020-08-30', 
                lastOnline: '5小时前',
                certificates: [
                    {
                        name: '驾驶证',
                        number: 'C2208030001',
                        issuer: '马鞍山市公安局交通警察支队',
                        issueDate: '2020-08-30',
                        expiryDate: '2026-08-29',
                        status: 'valid'
                    }
                ]
            },
            { 
                id: 17, 
                name: '罗杰', 
                employeeId: 'EMP017', 
                position: '调度员', 
                department: '调度中心', 
                phone: '13800138017', 
                status: 'online', 
                gender: '男', 
                age: 27, 
                joinDate: '2023-04-20', 
                lastOnline: '刚刚',
                certificates: [
                    {
                        name: '调度员资格证',
                        number: 'DIS2023042001',
                        issuer: '马鞍山市急救中心',
                        issueDate: '2023-04-20',
                        expiryDate: '2026-04-19',
                        status: 'valid'
                    }
                ]
            },
            { 
                id: 18, 
                name: '梁雪', 
                employeeId: 'EMP018', 
                position: '医护人员', 
                department: '急救科', 
                phone: '13800138018', 
                status: 'busy', 
                gender: '女', 
                age: 30, 
                joinDate: '2021-12-10', 
                lastOnline: '12分钟前',
                certificates: [
                    {
                        name: '护士执业证',
                        number: 'NUR2021121001',
                        issuer: '安徽省卫生健康委员会',
                        issueDate: '2021-12-10',
                        expiryDate: '2026-12-09',
                        status: 'valid'
                    }
                ]
            },
            { 
                id: 19, 
                name: '谢峰', 
                employeeId: 'EMP019', 
                position: '司机', 
                department: '运输部', 
                phone: '13800138019', 
                status: 'online', 
                gender: '男', 
                age: 38, 
                joinDate: '2020-05-15', 
                lastOnline: '3分钟前',
                certificates: [
                    {
                        name: '驾驶证',
                        number: 'A2005051501',
                        issuer: '马鞍山市公安局交通警察支队',
                        issueDate: '2020-05-15',
                        expiryDate: '2026-05-14',
                        status: 'valid'
                    }
                ]
            },
            { 
                id: 20, 
                name: '韩梅', 
                employeeId: 'EMP020', 
                position: '调度员', 
                department: '调度中心', 
                phone: '13800138020', 
                status: 'leave', 
                gender: '女', 
                age: 26, 
                joinDate: '2022-10-08', 
                lastOnline: '2天前',
                certificates: [
                    {
                        name: '调度员资格证',
                        number: 'DIS2022100801',
                        issuer: '马鞍山市急救中心',
                        issueDate: '2022-10-08',
                        expiryDate: '2025-10-07',
                        status: 'expiring'
                    }
                ]
            },
            { 
                id: 21, 
                name: '唐明', 
                employeeId: 'EMP021', 
                position: '医护人员', 
                department: '急救科', 
                phone: '13800138021', 
                status: 'online', 
                gender: '男', 
                age: 33, 
                joinDate: '2021-09-22', 
                lastOnline: '刚刚',
                certificates: [
                    {
                        name: '医师资格证',
                        number: 'DOC2021092201',
                        issuer: '国家卫生健康委员会',
                        issueDate: '2021-09-22',
                        expiryDate: '2026-09-21',
                        status: 'valid'
                    }
                ]
            },
            { 
                id: 22, 
                name: '邓芳', 
                employeeId: 'EMP022', 
                position: '司机', 
                department: '运输部', 
                phone: '13800138022', 
                status: 'busy', 
                gender: '女', 
                age: 29, 
                joinDate: '2020-07-12', 
                lastOnline: '25分钟前',
                certificates: [
                    {
                        name: '驾驶证',
                        number: 'C2207012001',
                        issuer: '马鞍山市公安局交通警察支队',
                        issueDate: '2020-07-12',
                        expiryDate: '2026-07-11',
                        status: 'valid'
                    }
                ]
            },
            { 
                id: 23, 
                name: '曾辉', 
                employeeId: 'EMP023', 
                position: '调度员', 
                department: '调度中心', 
                phone: '13800138023', 
                status: 'online', 
                gender: '男', 
                age: 35, 
                joinDate: '2023-03-18', 
                lastOnline: '刚刚',
                certificates: [
                    {
                        name: '调度员资格证',
                        number: 'DIS2023031801',
                        issuer: '马鞍山市急救中心',
                        issueDate: '2023-03-18',
                        expiryDate: '2026-03-17',
                        status: 'valid'
                    }
                ]
            },
            { 
                id: 24, 
                name: '潘婷', 
                employeeId: 'EMP024', 
                position: '医护人员', 
                department: '急救科', 
                phone: '13800138024', 
                status: 'offline', 
                gender: '女', 
                age: 28, 
                joinDate: '2021-04-28', 
                lastOnline: '4小时前',
                certificates: [
                    {
                        name: '护士执业证',
                        number: 'NUR2021042801',
                        issuer: '安徽省卫生健康委员会',
                        issueDate: '2021-04-28',
                        expiryDate: '2026-04-27',
                        status: 'valid'
                    }
                ]
            },
            { 
                id: 25, 
                name: '蔡勇', 
                employeeId: 'EMP025', 
                position: '司机', 
                department: '运输部', 
                phone: '13800138025', 
                status: 'online', 
                gender: '男', 
                age: 40, 
                joinDate: '2019-11-20', 
                lastOnline: '1分钟前',
                certificates: [
                    {
                        name: '驾驶证',
                        number: 'A1911122001',
                        issuer: '马鞍山市公安局交通警察支队',
                        issueDate: '2019-11-20',
                        expiryDate: '2025-11-19',
                        status: 'expiring'
                    }
                ]
            }
        ];

        let selectedPerson = null;
        let currentFilter = 'all';
        let certificateCount = 0;
        let editingPersonId = null;

        // 初始化页面
        document.addEventListener('DOMContentLoaded', function() {
            renderPersonList(personsData);
            updateTime();
            setInterval(updateTime, 1000);
            
            // 绑定事件
            bindTabEvents();
            bindSearchEvents();
            bindFormEvents();
            
            // 初始化时直接显示陈曦的详细信息
            initializeDefaultPerson();
        });

        // 初始化默认显示陈曦的信息
        function initializeDefaultPerson() {
            const chenXi = personsData[0]; // 陈曦是第一个用户
            selectedPerson = chenXi;
            
            // 显示陈曦的详细信息
            showPersonDetail(chenXi);
            
            // 设置第一个用户卡片为激活状态
            setTimeout(() => {
                const firstCard = document.querySelector('.person-card');
                if (firstCard) {
                    firstCard.classList.add('active');
                }
            }, 100);
        }

        // 更新时间
        function updateTime() {
            const now = new Date();
            const timeStr = now.toLocaleString('zh-CN', { 
                year: 'numeric', 
                month: '2-digit', 
                day: '2-digit',
                hour: '2-digit',
                minute: '2-digit',
                second: '2-digit'
            });
            document.getElementById('currentTime').textContent = timeStr;
        }

        // 渲染人员列表
        function renderPersonList(persons) {
            const listContainer = document.getElementById('personList');
            listContainer.innerHTML = '';
            
            persons.forEach(person => {
                const statusClass = `status-${person.status}`;
                const statusText = {
                    'online': '在线',
                    'offline': '离线',
                    'busy': '忙碌',
                    'leave': '休假'
                }[person.status];
                
                const statusTextClass = `status-text-${person.status}`;
                
                const card = document.createElement('div');
                card.className = 'person-card p-3';
                card.innerHTML = `
                    <div class="flex items-start space-x-3">
                        <img src="https://picsum.photos/seed/${person.employeeId}/40/40.jpg" alt="${person.name}" class="w-10 h-10 rounded-full">
                        <div class="flex-1 min-w-0">
                            <div class="flex items-center justify-between mb-1">
                                <h4 class="font-medium text-gray-900 text-sm truncate">${person.name}</h4>
                                <span class="status-dot ${statusClass}" title="${statusText}"></span>
                            </div>
                            <p class="text-xs text-gray-600">${person.employeeId}</p>
                            <p class="text-xs text-gray-500">${person.position}</p>
                            <div class="flex items-center justify-between mt-2">
                                <span class="status-text ${statusTextClass}">${statusText}</span>
                                ${person.status !== 'online' ? `<span class="text-xs text-gray-400">最后在线: ${person.lastOnline}</span>` : ''}
                            </div>
                            <p class="text-xs text-gray-500 mt-1">
                                <i class="fas fa-phone text-xs mr-1"></i>${person.phone}
                            </p>
                        </div>
                    </div>
                `;
                
                card.addEventListener('click', () => selectPerson(person));
                listContainer.appendChild(card);
            });
        }

        // 选择人员
        function selectPerson(person) {
            selectedPerson = person;
            
            // 更新选中状态
            document.querySelectorAll('.person-card').forEach(card => {
                card.classList.remove('active');
            });
            if (event && event.currentTarget) {
                event.currentTarget.classList.add('active');
            }
            
            // 显示详细信息
            showPersonDetail(person);
        }

        // 显示人员详细信息
        function showPersonDetail(person) {
            const detailContent = document.getElementById('detailContent');
            
            // 生成证书HTML
            let certificatesHtml = '';
            if (person.certificates && person.certificates.length > 0) {
                certificatesHtml = person.certificates.map(cert => {
                    const statusClass = cert.status === 'valid' ? 'certificate-valid' : 
                                      cert.status === 'expiring' ? 'certificate-expiring' : 'certificate-expired';
                    const statusText = cert.status === 'valid' ? '有效' : 
                                      cert.status === 'expiring' ? '即将过期' : '已过期';
                    
                    return `
                        <div class="certificate-detail-card">
                            <div class="certificate-detail-header">
                                <div class="flex justify-between items-center">
                                    <h5 class="text-sm font-medium text-gray-900">${cert.name}</h5>
                                    <span class="certificate-status ${statusClass}">${statusText}</span>
                                </div>
                            </div>
                            <div class="certificate-detail-info">
                                <div><span>证书编号：</span><strong>${cert.number || '未填写'}</strong></div>
                                <div><span>发证机构：</span><strong>${cert.issuer || '未填写'}</strong></div>
                                <div><span>发证日期：</span><strong>${cert.issueDate || '未填写'}</strong></div>
                                <div><span>有效期至：</span><strong>${cert.expiryDate || '未填写'}</strong></div>
                            </div>
                        </div>
                    `;
                }).join('');
            } else {
                certificatesHtml = '<p class="text-sm text-gray-500">暂无证书信息</p>';
            }
            
            detailContent.innerHTML = `
                <div class="bg-gray-50 rounded-lg p-5">
                    <div class="flex items-start space-x-4 mb-6">
                        <img src="https://picsum.photos/seed/${person.employeeId}/80/80.jpg" alt="${person.name}" class="w-20 h-20 rounded-full">
                        <div class="flex-1">
                            <h3 class="text-lg font-semibold text-gray-900">${person.name}</h3>
                            <p class="text-gray-600 text-sm">${person.position} · ${person.department}</p>
                            <div class="flex items-center mt-2">
                                <span class="status-dot status-${person.status} mr-2"></span>
                                <span class="text-sm text-gray-600">${person.status === 'online' ? '在线' : person.status === 'busy' ? '忙碌' : person.status === 'leave' ? '休假' : '离线'}</span>
                                <span class="text-sm text-gray-500 ml-4">最后在线: ${person.lastOnline}</span>
                            </div>
                        </div>
                        <div class="flex space-x-2">
                            <button onclick="editPerson(${person.id})" class="px-3 py-2 bg-blue-600 text-white text-sm rounded-lg hover:bg-blue-700 transition-colors">
                                <i class="fas fa-edit mr-1"></i>编辑
                            </button>
                            <button onclick="deletePerson(${person.id})" class="px-3 py-2 bg-red-600 text-white text-sm rounded-lg hover:bg-red-700 transition-colors">
                                <i class="fas fa-trash mr-1"></i>删除
                            </button>
                        </div>
                    </div>
                    
                    <div class="grid grid-cols-3 gap-4">
                        <div class="bg-white rounded-lg p-4 border border-gray-200">
                            <h4 class="text-sm font-medium text-gray-700 mb-3">
                                <i class="fas fa-user text-blue-600 mr-2"></i>基本信息
                            </h4>
                            <div class="space-y-2">
                                <div class="flex justify-between">
                                    <span class="text-xs text-gray-500">性别:</span>
                                    <span class="text-sm text-gray-900">${person.gender}</span>
                                </div>
                                <div class="flex justify-between">
                                    <span class="text-xs text-gray-500">年龄:</span>
                                    <span class="text-sm text-gray-900">${person.age}岁</span>
                                </div>
                                <div class="flex justify-between">
                                    <span class="text-xs text-gray-500">联系方式:</span>
                                    <span class="text-sm text-gray-900">${person.phone}</span>
                                </div>
                                <div class="flex justify-between">
                                    <span class="text-xs text-gray-500">邮箱:</span>
                                    <span class="text-sm text-gray-900">${person.employeeId}@company.com</span>
                                </div>
                            </div>
                        </div>
                        
                        <div class="bg-white rounded-lg p-4 border border-gray-200">
                            <h4 class="text-sm font-medium text-gray-700 mb-3">
                                <i class="fas fa-briefcase text-green-600 mr-2"></i>职业信息
                            </h4>
                            <div class="space-y-2">
                                <div class="flex justify-between">
                                    <span class="text-xs text-gray-500">工号:</span>
                                    <span class="text-sm text-gray-900">${person.employeeId}</span>
                                </div>
                                <div class="flex justify-between">
                                    <span class="text-xs text-gray-500">岗位:</span>
                                    <span class="text-sm text-gray-900">${person.position}</span>
                                </div>
                                <div class="flex justify-between">
                                    <span class="text-xs text-gray-500">部门:</span>
                                    <span class="text-sm text-gray-900">${person.department}</span>
                                </div>
                                <div class="flex justify-between">
                                    <span class="text-xs text-gray-500">入职时间:</span>
                                    <span class="text-sm text-gray-900">${person.joinDate}</span>
                                </div>
                                <div class="flex justify-between">
                                    <span class="text-xs text-gray-500">工作年限:</span>
                                    <span class="text-sm text-gray-900">${calculateWorkYears(person.joinDate)}年</span>
                                </div>
                            </div>
                        </div>
                        
                        <div class="bg-white rounded-lg p-4 border border-gray-200">
                            <h4 class="text-sm font-medium text-gray-700 mb-3">
                                <i class="fas fa-chart-line text-purple-600 mr-2"></i>工作统计
                            </h4>
                            <div class="space-y-2">
                                <div class="flex justify-between">
                                    <span class="text-xs text-gray-500">本月任务:</span>
                                    <span class="text-sm text-gray-900">${Math.floor(Math.random() * 50 + 30)}次</span>
                                </div>
                                <div class="flex justify-between">
                                    <span class="text-xs text-gray-500">总里程:</span>
                                    <span class="text-sm text-gray-900">${Math.floor(Math.random() * 5000 + 2000)}km</span>
                                </div>
                                <div class="flex justify-between">
                                    <span class="text-xs text-gray-500">评分:</span>
                                    <span class="text-yellow-500">
                                        <i class="fas fa-star"></i>
                                        <i class="fas fa-star"></i>
                                        <i class="fas fa-star"></i>
                                        <i class="fas fa-star"></i>
                                        <i class="fas fa-star-half-alt"></i>
                                        ${(Math.random() * 1 + 4).toFixed(1)}
                                    </span>
                                </div>
                                <div class="flex justify-between">
                                    <span class="text-xs text-gray-500">完成率:</span>
                                    <span class="text-green-600 font-bold text-sm">${(Math.random() * 10 + 90).toFixed(1)}%</span>
                                </div>
                            </div>
                        </div>
                    </div>

                    <!-- 额外的详细信息 -->
                    <div class="grid grid-cols-2 gap-4 mt-4">
                        <div class="bg-white rounded-lg p-4 border border-gray-200">
                            <h4 class="text-sm font-medium text-gray-700 mb-3">
                                <i class="fas fa-certificate text-orange-600 mr-2"></i>资质证书
                            </h4>
                            <div class="space-y-2 max-h-64 overflow-y-auto">
                                ${certificatesHtml}
                            </div>
                        </div>
                        
                        <div class="bg-white rounded-lg p-4 border border-gray-200">
                            <h4 class="text-sm font-medium text-gray-700 mb-3">
                                <i class="fas fa-history text-indigo-600 mr-2"></i>最近任务
                            </h4>
                            <div class="space-y-2">
                                <div class="flex items-center justify-between p-2 bg-gray-50 rounded">
                                    <div>
                                        <p class="text-sm font-medium">市中心医院转运</p>
                                        <p class="text-xs text-gray-500">2024-01-15 14:30</p>
                                    </div>
                                    <span class="text-xs text-green-600">完成</span>
                                </div>
                                <div class="flex items-center justify-between p-2 bg-gray-50 rounded">
                                    <div>
                                        <p class="text-sm font-medium">康复中心接送</p>
                                        <p class="text-xs text-gray-500">2024-01-15 09:15</p>
                                    </div>
                                    <span class="text-xs text-green-600">完成</span>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            `;
        }

        // 计算工作年限
        function calculateWorkYears(joinDate) {
            const join = new Date(joinDate);
            const now = new Date();
            return now.getFullYear() - join.getFullYear();
        }

        // 绑定标签页事件
        function bindTabEvents() {
            // 人员分类标签
            document.querySelectorAll('.tab-btn').forEach(btn => {
                btn.addEventListener('click', function() {
                    document.querySelectorAll('.tab-btn').forEach(b => {
                        b.classList.remove('text-blue-600', 'border-b-2', 'border-blue-600');
                        b.classList.add('text-gray-600');
                    });
                    this.classList.remove('text-gray-600');
                    this.classList.add('text-blue-600', 'border-b-2', 'border-blue-600');
                    
                    currentFilter = this.dataset.tab;
                    filterPersons();
                });
            });
        }

        // 绑定搜索事件
        function bindSearchEvents() {
            const searchInput = document.getElementById('searchInput');
            searchInput.addEventListener('input', function() {
                filterPersons();
            });
        }

        // 过滤人员
        function filterPersons() {
            const searchTerm = document.getElementById('searchInput').value.toLowerCase();
            let filtered = personsData;
            
            // 按分类过滤
            if (currentFilter !== 'all') {
                const positionMap = {
                    'medical': '医护人员',
                    'driver': '司机',
                    'dispatcher': '调度员'
                };
                filtered = filtered.filter(p => p.position === positionMap[currentFilter]);
            }
            
            // 按搜索词过滤
            if (searchTerm) {
                filtered = filtered.filter(p => 
                    p.name.toLowerCase().includes(searchTerm) ||
                    p.employeeId.toLowerCase().includes(searchTerm) ||
                    p.department.toLowerCase().includes(searchTerm)
                );
            }
            
            renderPersonList(filtered);
        }

        // 绑定表单事件
        function bindFormEvents() {
            const form = document.getElementById('addPersonForm');
            form.addEventListener('submit', function(e) {
                e.preventDefault();
                
                // 收集证书数据
                const certificates = [];
                document.querySelectorAll('.certificate-item').forEach(item => {
                    const certData = {
                        name: item.querySelector('[name="certName"]').value,
                        number: item.querySelector('[name="certNumber"]').value,
                        issuer: item.querySelector('[name="certIssuer"]').value,
                        issueDate: item.querySelector('[name="certIssueDate"]').value,
                        expiryDate: item.querySelector('[name="certExpiryDate"]').value,
                        status: getCertificateStatus(item.querySelector('[name="certExpiryDate"]').value)
                    };
                    certificates.push(certData);
                });
                
                // 模拟保存
                const formData = new FormData(form);
                
                if (editingPersonId) {
                    // 编辑模式
                    const personIndex = personsData.findIndex(p => p.id === editingPersonId);
                    if (personIndex !== -1) {
                        personsData[personIndex] = {
                            ...personsData[personIndex],
                            name: formData.get('name'),
                            employeeId: formData.get('employeeId'),
                            position: formData.get('position'),
                            department: formData.get('department'),
                            phone: formData.get('phone'),
                            gender: formData.get('gender'),
                            age: formData.get('age'),
                            joinDate: formData.get('joinDate'),
                            certificates: certificates
                        };
                        showNotification('更新成功', 'success');
                    }
                } else {
                    // 新增模式
                    const newPerson = {
                        id: personsData.length + 1,
                        name: formData.get('name'),
                        employeeId: formData.get('employeeId'),
                        position: formData.get('position'),
                        department: formData.get('department'),
                        phone: formData.get('phone'),
                        gender: formData.get('gender'),
                        age: formData.get('age'),
                        joinDate: formData.get('joinDate'),
                        status: 'online',
                        lastOnline: '刚刚',
                        certificates: certificates
                    };
                    personsData.push(newPerson);
                    showNotification('添加成功', 'success');
                }
                
                renderPersonList(personsData);
                closeModal();
            });
        }

        // 添加证书
        function addCertificate(name = '') {
            certificateCount++;
            const certificatesList = document.getElementById('certificatesList');
            const certificateItem = document.createElement('div');
            certificateItem.className = 'certificate-item';
            certificateItem.innerHTML = `
                <div class="flex justify-between items-center mb-3">
                    <h5 class="text-sm font-medium text-gray-700">证书 #${certificateCount}</h5>
                    <button type="button" onclick="removeCertificate(this)" class="remove-certificate-btn">
                        <i class="fas fa-times-circle"></i>
                    </button>
                </div>
                <div class="certificate-form-row">
                    <div>
                        <label class="block text-xs font-medium text-gray-600 mb-1">证书名称 *</label>
                        <input type="text" name="certName" value="${name}" required class="w-full px-2 py-1 text-sm border border-gray-300 rounded focus:outline-none focus:border-blue-500">
                    </div>
                    <div>
                        <label class="block text-xs font-medium text-gray-600 mb-1">证书编号</label>
                        <input type="text" name="certNumber" class="w-full px-2 py-1 text-sm border border-gray-300 rounded focus:outline-none focus:border-blue-500">
                    </div>
                </div>
                <div class="certificate-form-row">
                    <div>
                        <label class="block text-xs font-medium text-gray-600 mb-1">发证机构</label>
                        <input type="text" name="certIssuer" class="w-full px-2 py-1 text-sm border border-gray-300 rounded focus:outline-none focus:border-blue-500">
                    </div>
                    <div>
                        <label class="block text-xs font-medium text-gray-600 mb-1">发证日期</label>
                        <input type="date" name="certIssueDate" class="w-full px-2 py-1 text-sm border border-gray-300 rounded focus:outline-none focus:border-blue-500">
                    </div>
                </div>
                <div class="certificate-form-row full-width">
                    <div>
                        <label class="block text-xs font-medium text-gray-600 mb-1">有效期至 *</label>
                        <input type="date" name="certExpiryDate" required class="w-full px-2 py-1 text-sm border border-gray-300 rounded focus:outline-none focus:border-blue-500" onchange="updateCertificateStatus(this)">
                    </div>
                </div>
            `;
            certificatesList.appendChild(certificateItem);
        }

        // 移除证书
        function removeCertificate(button) {
            const certificateItem = button.closest('.certificate-item');
            certificateItem.remove();
        }

        // 选择常用证书
        function selectCommonCertificate(element, certificateName) {
            // 添加证书
            addCertificate(certificateName);
            
            // 添加选中效果
            element.classList.add('selected');
            setTimeout(() => {
                element.classList.remove('selected');
            }, 500);
        }

        // 获取证书状态
        function getCertificateStatus(expiryDate) {
            if (!expiryDate) return 'valid';
            
            const today = new Date();
            const expiry = new Date(expiryDate);
            const diffTime = expiry - today;
            const diffDays = Math.ceil(diffTime / (1000 * 60 * 60 * 24));
            
            if (diffDays < 0) {
                return 'expired';
            } else if (diffDays <= 90) {
                return 'expiring';
            } else {
                return 'valid';
            }
        }

        // 更新证书状态显示
        function updateCertificateStatus(input) {
            const status = getCertificateStatus(input.value);
            // 这里可以添加状态显示逻辑
        }

        // 显示添加模态框
        function showAddModal() {
            document.getElementById('addModal').classList.add('show');
            // 重置证书计数
            certificateCount = 0;
            // 清空证书列表
            document.getElementById('certificatesList').innerHTML = '';
            // 重置编辑状态
            editingPersonId = null;
            // 更新标题
            document.querySelector('#addModal h3').innerHTML = '<i class="fas fa-user-plus text-blue-600 mr-2"></i>添加新员工';
        }

        // 关闭模态框
        function closeModal() {
            document.getElementById('addModal').classList.remove('show');
            document.getElementById('addPersonForm').reset();
            // 清空证书列表
            document.getElementById('certificatesList').innerHTML = '';
            certificateCount = 0;
            editingPersonId = null;
        }

        // 编辑人员
        function editPerson(id) {
            const person = personsData.find(p => p.id === id);
            if (person) {
                // 设置编辑状态
                editingPersonId = id;
                
                // 填充表单
                const form = document.getElementById('addPersonForm');
                form.name.value = person.name;
                form.employeeId.value = person.employeeId;
                form.gender.value = person.gender;
                form.age.value = person.age;
                form.position.value = person.position;
                form.department.value = person.department;
                form.phone.value = person.phone;
                form.joinDate.value = person.joinDate;
                
                // 更新标题
                document.querySelector('#addModal h3').innerHTML = '<i class="fas fa-user-edit text-blue-600 mr-2"></i>编辑员工信息';
                
                // 清空并重新加载证书列表
                document.getElementById('certificatesList').innerHTML = '';
                certificateCount = 0;
                
                // 如果有证书数据，填充证书
                if (person.certificates && person.certificates.length > 0) {
                    person.certificates.forEach(cert => {
                        addCertificate(cert.name);
                        const lastItem = document.querySelector('.certificate-item:last-child');
                        lastItem.querySelector('[name="certNumber"]').value = cert.number || '';
                        lastItem.querySelector('[name="certIssuer"]').value = cert.issuer || '';
                        lastItem.querySelector('[name="certIssueDate"]').value = cert.issueDate || '';
                        lastItem.querySelector('[name="certExpiryDate"]').value = cert.expiryDate || '';
                    });
                }
                
                showAddModal();
            }
        }

        // 删除人员
        function deletePerson(id) {
            showConfirmDialog('确定要删除该人员吗？此操作不可恢复。', () => {
                const index = personsData.findIndex(p => p.id === id);
                if (index > -1) {
                    personsData.splice(index, 1);
                    renderPersonList(personsData);
                    
                    // 如果删除的是当前选中的用户，显示提示信息
                    if (selectedPerson && selectedPerson.id === id) {
                        document.getElementById('detailContent').innerHTML = `
                            <div class="text-center py-12 text-gray-500">
                                <i class="fas fa-user-circle text-6xl mb-4"></i>
                                <p>请从左侧选择一个人员查看详细信息</p>
                            </div>
                        `;
                    }
                    
                    showNotification('删除成功', 'success');
                }
            });
        }

        // 显示确认对话框
        function showConfirmDialog(message, onConfirm) {
            document.getElementById('confirmMessage').textContent = message;
            document.getElementById('confirmDialog').classList.add('show');
            
            document.getElementById('confirmBtn').onclick = function() {
                onConfirm();
                closeConfirmDialog();
            };
        }

        // 关闭确认对话框
        function closeConfirmDialog() {
            document.getElementById('confirmDialog').classList.remove('show');
        }

        // 显示通知
        function showNotification(message, type) {
            const notification = document.createElement('div');
            notification.className = `fixed top-20 right-4 px-6 py-3 rounded-lg shadow-lg z-50 ${
                type === 'success' ? 'bg-green-500' : 'bg-red-500'
            } text-white`;
            notification.innerHTML = `
                <div class="flex items-center">
                    <i class="fas ${type === 'success' ? 'fa-check-circle' : 'fa-exclamation-circle'} mr-2"></i>
                    <span>${message}</span>
                </div>
            `;
            
            document.body.appendChild(notification);
            
            setTimeout(() => {
                notification.style.animation = 'fadeOut 0.3s ease';
                setTimeout(() => {
                    document.body.removeChild(notification);
                }, 300);
            }, 3000);
        }

        // 添加淡出动画
        const style = document.createElement('style');
        style.textContent = `
            @keyframes fadeOut {
                from { opacity: 1; transform: translateX(0); }
                to { opacity: 0; transform: translateX(100px); }
            }
        `;
        document.head.appendChild(style);
    </script>
</body>
</html>